<?php
class kwitansimutasigiro_model extends CI_Model{
	private $NoKwitansi;
    private $NoFaktur;
    private $KodeSupplier;
    private $KodeBarang;
  	private $TotalQuantity;
	private $Discount;
	private $TotalAmount_In;
	private $TotalAmount_Out;
    private $Typebayar;
	private $Bankname;
    private $Nogiro;
    private $Tanggalterbit;
	private $Tanggalcair;
    private $Keterangan;
    private $createdby;
    private $createdon;
    private $lastupdateby;
  	private $lastupdateon;
  	private $active;
	
	function setNoKwitansi($nokwitansi){
		$this->NoKwitansi = $nokwitansi;
	}
	function getNoKwitansi(){
		return $this->NoKwitansi;
	}
	
	function setNoFaktur($nofaktur){
		$this->NoFaktur = $nofaktur;
	}
	function getNoFaktur(){
		return $this->NoFaktur;
	}
	
	function setKodeSupplier($kdsupp){
		$this->KodeSupplier = $kdsupp;
	}
	function getKodeSupplier(){
		return $this->KodeSupplier;
	}
	
	function setKodeBarang($kdbarang){
		$this->KodeBarang = $kdbarang;
	}
	function getKodeBarang(){
		return $this->KodeBarang;
	}
	
	function setTotalQuantity($ttlqty){
		$this->TotalQuantity = $ttlqty;
	}
	function getTotalQuantity(){
		return $this->TotalQuantity;
	}
	
	function setDiscount($discount){
		$this->Discount = $discount;
	}

	function getDiscount(){
		return $this->Discount;
	}
	
	function setTotalAmount_In($ttlamountin){
		$this->TotalAmount_In = $ttlamountin;
	}

	function getTotalAmount_In(){
		return $this->TotalAmount_In;
	}
	
	function setTotalAmount_Out($ttlamountout){
		$this->TotalAmount_Out = $ttlamountout;
	}

	function getTotalAmount_Out(){
		return $this->TotalAmount_Out;
	}
	
	function setTypebayar($tipebyr){
		$this->Typebayar = $tipebyr;
	}

	function getTypebayar(){
		return $this->Typebayar;
	}
	
	function setBankname($namabank){
		$this->Bankname = $namabank;
	}

	function getBankname(){
		return $this->Bankname;
	}
	
	function setNogiro($nogiro){
		$this->Nogiro = $nogiro;
	}

	function getNogiro(){
		return $this->Nogiro;
	}

	function setTanggalterbit($tglterbit){
		$this->Tanggalterbit = $tglterbit;
	}

	function getTanggalterbit(){
		return $this->Tanggalterbit;
	}

	function setTanggalcair($tglcair){
		$this->Tanggalcair = $tglcair;
	}

	function getTanggalcair(){
		return $this->Tanggalcair;
	}
	
	function setKeterangan($ket){
		$this->Keterangan = $ket;
	}

	function getKeterangan(){
		return $this->Keterangan;
	}
	
	function setCreatedBy($c_by){
		$this->createdby = $c_by;
	}

	function getCreatedBy(){
		return $this->createdby;
	}

	function setCreatedOn(){
		$dateNow = date('Y-m-d H:i:s');
		$this->createdon = $dateNow;
	}

	function getCreatedOn(){
		return $this->createdon;
	}

	function setLastUpdateBy($u_by){
		$this->lastupdateby = $u_by;
	}

	function getLastUpdateBy(){
		return $this->lastupdateby;
	}

	function setLastUpdateOn(){
		$dateNow = date('Y-m-d H:i:s');
		$this->lastupdateon = $dateNow;
	}

	function getLastUpdateOn(){
		return $this->lastupdateon;
	}

	function setActive($active_val){
		$this->active = $active_val;
	}

	function getActive(){
		return $this->active;
	}
	// Call the module constructor
	function __construct(){
		parent::__construct();
	}
	
	function insert()
	{
		/*$query = $this->db->query("select max(NoFaktur) id from kwitansi");
        $nofktr = $query->result();
        $this->setNoFaktur(($nofktr[0]->nofaktur) + 1);*/
		$data = array(
			'NoKwitansi' => $this->getNoKwitansi(),
			'NoFaktur' => $this->getNoFaktur(),
			'TotalQuantity' => $this->getTotalQuantity(),
			'Discount' => $this->getDiscount(),
			'TotalAmount_In' => $this->getTotalAmount_In(),
			'TotalAmount_Out' => $this->getTotalAmount_Out(),
			'Bankname' => $this->getBankname(),
			'Nogiro' => $this->getNogiro(),
			'Tanggalterbit' => $this->getTanggalterbit(),
			'Tanggalcair' => $this->getTanggalcair(),
			'Keterangan' => $this->getKeterangan(),
			'createdby' => $this->getCreatedBy(),
			'createdon' => $this->getCreatedOn(),
			'lastupdateby' => 'null',
			'lastupdateon' => 'null',

			'active' => $this->getActive()						
		);
		$this->db->insert('mutasi_giro',$data);
	}
	
	function update(){
		$data = array();
		if($this->getNoFaktur()){
			$data['NoFaktur'] = $this->getNoFaktur();
		}
		if($this->getTotalQuantity()){
			$data['TotalQuantity'] = $this->getTotalQuantity();
		}
		if($this->getDiscount()){
			$data['Discount'] = $this->getDiscount();
		}
		if($this->getTotalAmount_In()){
			$data['TotalAmount_In'] = $this->getTotalAmount_In();
		}
		if($this->getTotalAmount_Out()){
			$data['TotalAmount_Out'] = $this->getTotalAmount_Out();
		}
		if($this->getBankname()){
			$data['Bankname'] = $this->getBankname();
		}
		if($this->getNogiro()){
			$data['Nogiro'] = $this->getNogiro();
		}
		if($this->getTanggalterbit()){
			$data['Tanggalterbit'] = $this->getTanggalterbit();
		}
		if($this->getTanggalcair()){
			$data['Tanggalcair'] = $this->getTanggalcair();
		}
		if($this->getKeterangan()){
			$data['Keterangan'] = $this->getKeterangan();
		}
		if($this->getLastUpdateBy()){
			$data['lastupdateby'] = $this->getLastUpdateBy();
		}
		if($this->getLastUpdateOn()){
			$data['lastupdateon'] = $this->getLastUpdateOn();
		}
		$this->db->where('NoKwitansi',$this->getNoKwitansi());
		$this->db->update('mutasi_giro',$data);
	}
	
	function getList(){
		 $this->db->select()
                ->where(array('active'=>'1'))->order_by('NoKwitansi', 'ASC');
        $query = $this->db->get('mutasi_giro');
        return $query->result();
	}
	
	function getlistnofaktur() {
        $this->db->select()
                ->where(array('kwitansi.NoKwitansi' => $this->getNoKwitansi()));
        $query = $this->db->get('mutasi_giro');
        return $query->result();
    }
}